package com.banshou.installs.ui.adapter;

import android.content.Context;
import android.view.View;

import com.banshou.installs.R;
import com.banshou.installs.model.dao.ResponseInstallHis;
import com.blankj.utilcode.util.TimeUtils;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.List;

/**
 * Created by cjq on 2018/1/3.
 * Email: stoic_yb@139.com
 * features:
 */

public class InstallHisAdapter extends CommonAdapter<ResponseInstallHis.map> {

    public OnItemClickListener listener;

    public void setListener(OnItemClickListener listener) {
        this.listener = listener;
    }

    public interface OnItemClickListener {
        void setId(String id,int position);
    }

    public InstallHisAdapter(Context context, int layoutId, List<ResponseInstallHis.map> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convert(ViewHolder holder, final ResponseInstallHis.map map, final int position) {
        holder.setText(R.id.tv_name, map.getOrg().getLabel().concat(map.getBuilding().getLabel()).concat(map.getUnit().getLabel()));
        holder.setText(R.id.tv_add, map.getId());
        holder.setText(R.id.tv_floor, map.getStartFloor().concat("-").concat(map.getEndFloor()));
        holder.setText(R.id.tv_time, map.getCreateTime());
        holder.setOnClickListener(R.id.main, view -> listener.setId(map.getId(),position));
    }
}
